* @file
*/
use MediaWiki\ChangeTags\Taggable;
+use MediaWiki\MediaWikiServices;
/**
* Utility class for creating new RC entries
public function save( $send = self::SEND_FEED ) {
global $wgPutIPinRC, $wgUseEnotif, $wgShowUpdatedMarker;
- if ( is_string( $send ) ) {
- // Callers used to pass undocumented strings like 'noudp'
- // or 'pleasedontudp' instead of self::SEND_NONE (true).
- // @deprecated since 1.31 Use SEND_NONE instead.
- $send = self::SEND_NONE;
- }
-
$dbw = wfGetDB( DB_MASTER );
if ( !is_array( $this->mExtra ) ) {
$this->mExtra = [];
public function doMarkPatrolled( User $user, $auto = false, $tags = null ) {
global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol;
+ // Fix up $tags so that the MarkPatrolled hook below always gets an array
+ if ( $tags === null ) {
+ $tags = [];
+ } elseif ( is_string( $tags ) ) {
+ $tags = [ $tags ];
+ }
+
$errors = [];
// If recentchanges patrol is disabled, only new pages or new file versions
// can be patrolled, provided the appropriate config variable is set
$right = $auto ? 'autopatrol' : 'patrol';
$errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) );
if ( !Hooks::run( 'MarkPatrolled',
- [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ] )
+ [ $this->getAttribute( 'rc_id' ), &$user, false, $auto, &$tags ] )
) {
$errors[] = [ 'hookaborted' ];
}
// Users without the 'autopatrol' right can't patrol their
// own revisions
- if ( $user->getName() === $this->getAttribute( 'rc_user_text' )
- && !$user->isAllowed( 'autopatrol' )
+ if ( $user->getName() === $this->getAttribute( 'rc_user_text' ) &&
+ !MediaWikiServices::getInstance()->getPermissionManager()
+ ->userHasRight( $user, 'autopatrol' )
) {
$errors[] = [ 'markedaspatrollederror-noautopatrol' ];
}
$type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
$revId = 0, $isPatrollable = false ) {
global $wgRequest;
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
# # Get pageStatus for email notification
switch ( $type . '-' . $action ) {
}
// Allow unpatrolled status for patrollable log entries
- $markPatrolled = $isPatrollable ? $user->isAllowed( 'autopatrol' ) : true;
+ $canAutopatrol = $permissionManager->userHasRight( $user, 'autopatrol' );
+ $markPatrolled = $isPatrollable ? $canAutopatrol : true;
$rc = new RecentChange;
$rc->mTitle = $target;
'rc_comment_data' => null,
'rc_this_oldid' => $revId,
'rc_last_oldid' => 0,
- 'rc_bot' => $user->isAllowed( 'bot' ) ? (int)$wgRequest->getBool( 'bot', true ) : 0,
+ 'rc_bot' => $permissionManager->userHasRight( $user, 'bot' ) ?
+ (int)$wgRequest->getBool( 'bot', true ) : 0,
'rc_ip' => self::checkIPAddress( $ip ),
'rc_patrolled' => $markPatrolled ? self::PRC_AUTOPATROLLED : self::PRC_UNPATROLLED,
'rc_new' => 0, # obsolete